﻿using System;
using System.Data.SqlClient;
using System.Windows;
using System.Windows.Controls;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using Microsoft.Extensions.Configuration;




namespace black_screen_mode_server.Pages
{
    /// <summary>
    /// ParametesSetupPage.xaml 的交互逻辑
    /// </summary>
    public partial class ParametesSetupPage : Page
    {
        public ParametesSetupPage()
        {
            InitializeComponent();
            LoadInitialParameterData();
        }

        //点击确认
        private void btnParameterConfirm_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ProjectTools.WriteConfig("parametersInfo", "delay_time", txtDelayTime.Text);
                ProjectTools.WriteConfig("parametersInfo", "ignore", txtIgnore.Text);
                MessageBox.Show("更新成功！", "提示");
                //持久化数据到配置文件
            }
            catch (Exception ex)
            {
                MessageBox.Show("更新失败！" + ex.Message, "提示");
            }
        }

        //初始化读取数据
        private void LoadInitialParameterData()
        {
            txtDelayTime.Text = ProjectTools.ReadConfig("parametersInfo", "delay_time");
            txtIgnore.Text = ProjectTools.ReadConfig("parametersInfo", "ignore");
        }
    }

}
